﻿using SimpleORMNET;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Sample_WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public ObservableCollection<Person> People { get; set; }

        string connectionString = @"Data Source=LUKI-PC\SQLEXPRESS;Initial Catalog=AdventureWorks2012;Integrated Security=True";

        SqlDatabaseReader db;

        public MainWindow()
        {
            InitializeComponent();

            db = new SqlDatabaseReader(connectionString);
            People = new ObservableCollection<Person>();

            this.DataContext = this;
        }

        private async void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            this.Cursor = Cursors.Wait;
            cmd.IsEnabled = false;
            var result = await db.GetAsync<Person>("SELECT TOP 10000 * FROM [AdventureWorks2012].[Person].[Person]");
            foreach (var item in result)
            {
                People.Add(item);
            }
            cmd.IsEnabled = true;
            this.Cursor = Cursors.Arrow;
        }
    }
}
